package com.coder.rental.utils;

import jdk.jfr.Registered;
import lombok.Data;
import lombok.experimental.Accessors;
import org.apache.poi.ss.formula.functions.T;

@Data
@Accessors(chain = true)
public class Result<T> {
    private String message;
    private Integer code;
    private Boolean success;
    private T data;

    private Result(){

    }


    public static <T> Result<T> success(){
        Result<T> result=new Result<T>();
        result.setCode(ResultCode.SUCCESS);
        result.setSuccess(true);
        return result;
    }
    public static <T> Result<T> success(T data){
        Result<T> result=new Result<T>();
        result.setCode(ResultCode.SUCCESS);
        result.setSuccess(true);
        result.setData(data);
        return result;
    }

    public static <T> Result<T> error(){
        Result<T> result=new Result<T>();
        result.setCode(ResultCode.ERROR);
        result.setSuccess(false);
        return result;
    }
    public static <T> Result<T> error(T data){
        Result<T> result=new Result<T>();
        result.setCode(ResultCode.ERROR);
        result.setSuccess(false);
        result.setData(data);
        return result;
    }




}
